#include "main.h"
#include "stdlib.h"
#include "string.h"
#include "stdio.h"
#include "math.h"

#include "bsp_led.h"
#include "bsp_key.h"
#include "bsp_beep.h"
#include "motor.h"
#include "bsp_pwm.h"
#include "bsp_basic_timer.h"
#include "bsp_hcsr.h"
#include "bluetooth.h"
#include "bsp_usart.h"
#include "adc.h"
#include "bsp_spi_bus.h"
#include "oled.h"
#include "nrf24l01.h"
#include "bmp.h"

#include "task_loop.h"


//void print_array(uint8_t str[])
//{
//	for (int i = 0; str[i] != '\0'; i++)
//		printf("str[%d]%c\n", i, str[i]);
//}

int main(void)
{
	nvic_priority_group_set(NVIC_PRIGROUP_PRE2_SUB2);
	systick_config();
	usart_gpio_config(115200);
	uart6_gpio_config(115200);
	uart5_Init(115200);
	led_gpio_config();
	motor_gpio_config();
	pwm1_config(200, 500);
	pwm2_config(200, 500);
	car_stop(0);
	adc_config();
	beep_gpio_config();
	spi_bus_init();
	spi_lcd_gpio_Init();
	OLED_Init();
	OLED_ShowPicture(0, 15, 128, 32, BMPLOGO, 1);
	OLED_Refresh();
	key_gpio_config();
	hcsr04_gpio_config();
	basic_timer_config(20000, 10000); // 1s
	NRF24L01_Init();
	NRF24L01_Check_detection();

	while (1)
	{
		Control();
	}
}
